<template>
  <div class="app-container">
    <div class="zd3">
      <div class="zd3-title">
        <p>
          <span>标题</span>
          <input v-model="content" type="text" placeholder="请输入随手拍标题" />
        </p>
        <h3 @click="getList">查询</h3>
        <h4 @click="resetList">重置</h4>
				<h3 @click="addpeople" style="background: #0093FF">新增</h3>
      </div>
      <div class="zd3-btm">
        <el-table
          :data="tableData"
          style="width: 100%;border-radius: 8px;"
          :show-header="showHeader"
          v-loading="loading"
        >
          <el-table-column type="index" align="center" label="序号" width="80" />
					<el-table-column align="center" prop="exceedTime" label="是否逾期" />
					<el-table-column align="center" prop="chuliTime" label="处理时长" />
					<el-table-column align="center" width="200" label="内容" >
						<template slot-scope="scope">
							<div class="ellisp">{{scope.row.content}}</div>
						</template>
					</el-table-column>
					<el-table-column align="center" prop="locations" label="地址" />
          <el-table-column align="center" prop="resultContent" label="反馈内容 " />
          <el-table-column align="center" width="100" prop="content" label="图片">
            <template slot-scope="scope">
              <img :src="scope.row.imgurl" alt="" class="s-img">
              <!-- <a href="@/assets/img/logo.jpg"></a>  -->
            </template>
          </el-table-column>
          <el-table-column align="center" prop="resultPer" label="处理人" />
          <!-- <el-table-column align="center" prop="status" label="状态" width="100" /> -->
          <el-table-column align="center" width="200" label="操作">
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="look(scope.row)">查看</el-button>
              <el-button type="text" size="small" @click="write(scope.row,scope.$index)">编辑</el-button>
              <el-button type="text" v-if="scope.row.imgurl" size="small" @click="downloadImg(scope.row)">下载图片</el-button>
              <el-popconfirm
                placement="top"
                hideIcon
                title="是否要删除此行？"
                @onConfirm="deleteRow(scope.row)"
              >
                <el-button type="text" size="small" slot="reference">删除</el-button>
              </el-popconfirm>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          background
					align="right"
					:page-size="50"
          layout="prev, pager, next"
          :total="total"
					@current-change='goPage'
          @prev-click="goPrev"
          @next-click="goNext"
        />
      </div>
    </div>
    <!-- <el-dialog
      :visible.sync="dialogVisible"
      :modal-append-to-body="false"
      :modal="true"
      :close-on-click-modal="false"
      width="70%"
    >
      <div class="change">
        <p>
          <span>内容</span>
          <input v-model="tempData.content" type="text" placeholder="请输入内容" />
        </p>
        <p>
          <span>状态</span>
          <input v-model="tempData.status" type="text" placeholder="请输入状态" />
        </p>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取消</el-button>
        <el-button type="primary" @click="save">保存</el-button>
      </div>
    </el-dialog> -->
  </div>
</template>

<script>
import {
  getSuiShou,
  addSuiShou,
  updateSuiShou,
  deleteSuiShou
} from "@/api/oneclassify";
export default {
  data() {
    return {
      content: "",
      total: 1,
      page: 1,
      showHeader: true,
      loading: true,
      tableData: [],
      dialogVisible: false,
      tempData: "",
      tempIndex: -1
    };
  },
  mounted() {
    this.getList();
  },
  methods: {
    getList() {
      const param = {
        content: this.content ? this.content : null,
        currentPage: this.page
      };
      getSuiShou(param).then(res => {
        console.log(res);
        this.tableData = res.data.list;
        this.total = res.data.total;
        this.loading = false;
      });
    },
    downloadImg(item){
      window.open(item.imgurl)
    },
    look(item){
      this.$router.push({
        name: 'Writereadilytake',
        params: {
          options: JSON.stringify(item),
          look: true
        }
      })
    },
    write(item, index) {
      console.log(item);
      this.tempIndex = index;
			this.$router.push({
				name: 'Writereadilytake',
				params: {
					options: JSON.stringify(item)
				}
			})
      // this.tempData = { ...item };
      // this.dialogVisible = true;
    },
    save() {
      if (this.tempIndex == -1) {
        addSuiShou(this.tempData).then(res => {
          console.log(res);
          this.$message({
            showClose: true,
            message: res.message,
            type: "success"
          });
          this.getList();
          this.dialogVisible = false;
        });
      } else {
        updateSuiShou(this.tempData).then(res => {
          console.log(res);
          this.$message({
            showClose: true,
            message: res.message,
            type: "success"
          });
          this.getList();
          this.dialogVisible = false;
        });
      }
    },
    deleteRow(item) {
      console.log("删除");
      deleteSuiShou(item.id).then(res => {
        console.log(res);
        this.$message({
          showClose: true,
          message: res.message,
          type: "success"
        });
        this.getList();
      });
    },
    goPrev(page) {
      console.log(page)
      this.page--
      this.getList()
    },
    goNext(page) {
      console.log(page)
      this.page++
      this.getList()
    },
    goPage(page){
      console.log(page)
      this.page = page
      this.getList()
    },
    resetList() {
      this.rolename = "";
    },
    addpeople() {
      this.$router.push({
      	name: 'Writereadilytake'
      })
    }
  }
};
</script>

<style lang="scss" scoped>
/deep/.el-button--primary {
  color: #fff;
  background-color: #18a05e !important;
  border-color: #18a05e !important;
}
/deep/.el-button--primary:hover,
.el-button--primary:focus {
  background: #18a05e !important;
  border-color: #18a05e !important;
  color: #fff !important;
}
/deep/.el-button:hover,
.el-button:focus {
  color: #18a05e;
  background-color: transparent;
}
/deep/.el-button--primary {
  color: #fff;
  background-color: #18a05e;
  border-color: #18a05e;
}
/deep/.el-button--text {
  color: #00c666 !important;
}
.ellisp{
	width: 100%;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
	text-align: left;
}
.app-container {
  padding: 10px;
}
.rolestip {
  width: 100%;
  display: flex;
  justify-content: center;
}
.inps {
  width: 100%;
  height: 32px;
  line-height: 32px;
  padding-left: 10px;
  background: none;
  border: none;
  color: #333;
}
.inps-active {
  width: 100%;
  height: 32px;
  line-height: 32px;
  padding-left: 10px;
  // background:#ccc;
  border: none;
  color: #333;
}
.s-img{
  width: 80px;
  height: 80px;
}
.zd3-title {
	height: 80px;
	display: flex;
	align-items: center;
	padding: 0 20px;
	position: relative;
	background: #ffffff;
	border-radius: 8px;
	border: 1px solid rgba(0, 0, 0, 0.1);

	> p {
		font-size: 14px;
		color: #333;
		margin-right: 30px;

		> span {
			padding-right: 20px;
		}

		> input {
			width: 200px;
			height: 32px;
			// background: #ccc;
			border-radius: 3px;
			border: 1px solid #ccc;
			padding-left: 10px;
			color: #333;
		}
	}

	> h3 {
		width: 64px;
		height: 32px;
		background: #18a05e;
		border-radius: 3px;
		margin: 0 30px 0 0;
		color: #fff;
		font-size: 14px;
		line-height: 32px;
		font-weight: 100;
		text-align: center;
		cursor: pointer;
	}

	> h4 {
		width: 64px;
		height: 32px;
		border-radius: 3px;
		border: 1px solid rgba(0, 0, 0, 0.1);
		color: #333;
		font-size: 14px;
		line-height: 32px;
		font-weight: 100;
		text-align: center;
		cursor: pointer;
		margin-right: 30px;
	}
}
/deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
  background-color: #18a05e;
  color: #fff;
}
.zd3-btm /deep/.btn-prev:after {
  content: "上一页";
}
.zd3-btm /deep/.btn-next:before {
  content: "下一页";
}
.zd3-btm /deep/.btn-prev,
.zd3-btm /deep/.btn-next {
  width: 65px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.zd3-btm {
  background: rgba(255, 255, 255, 1);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: 10px;
  overflow: hidden;
  &-title {
    display: flex;
    align-items: center;
    height: 70px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: #ffffff;
    > p {
      text-align: center;
      font-size: 16px;
      color: #333;
    }
  }
  .el-pagination {
		white-space: nowrap;
		padding: 15px 5px;
		color: #303133;
		font-weight: bold;
	}
  .addDate {
    margin: 20px 32px 10px 32px;
    height: 32px;
    border-radius: 3px;
    text-align: center;
    line-height: 32px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    border: 1px dashed rgba(0, 0, 0, 0.25);
  }
  .el-button--text {
    margin: 0 15px;
  }
}
.change {
  display: flex;
  flex-wrap: wrap;
  > p {
    width: 50%;
    font-size: 14px;
    display: flex;
    align-items: center;
    color: #333;
    /deep/.el-input__inner {
      width: inherit;
      background: none;
      height: 32px;
      // line-height: 32px;
      color: #333;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding: 0 25px;
    }
    /deep/.el-input__icon {
      line-height: 32px;
    }
    .userselect {
      // max-width: 250px;
      flex: 1;
    }

    > span {
      display: block;
      width: 120px;
      text-align: right;
      padding-right: 15px;
    }
    > input {
      width: inherit;
      flex: 1;
      height: 32px;
      border-radius: 3px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      padding-left: 10px;
      color: #333;
    }
  }
}
</style>
